'''键盘事件'''
from selenium import webdriver
# 引入keys 模块
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
driver.maximize_window()

# 输入框输入内容
driver.find_element_by_id('kw').send_keys('seleniumm')

#_ 删除多输入内容
driver.find_element_by_id('kw').send_keys(Keys.BACK_SPACE)

# 输入空格键+“教程”
driver.find_element_by_id('kw').send_keys(Keys.SPACE)
driver.find_element_by_id('kw').send_keys('教程')

# ctrl+a 全选输入框内容
driver.find_element_by_id('kw').send_keys(Keys.CONTROL,'a')

# ctrl+x 剪切内容到输入框
driver.find_element_by_id('kw').send_keys(Keys.CONTROL,'x')

# ctrl+v 粘贴内容到输入框
driver.find_element_by_id('kw').send_keys(Keys.CONTROL,'v')

# 通过 回车键来代替单击操作
driver.find_element_by_id('su').send_keys(Keys.ENTER)
# driver.quit()